package cn.bugstack.mybatis.mapping;

import cn.bugstack.mybatis.reflection.MetaObject;
import cn.bugstack.mybatis.session.Configuration;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BoundSql {

    private Configuration configuration;

    private String parameterType;


    /**
     * #{id, javaType=Integer, jdbcType=NUMERIC}
     */
    private List<ParameterMapping> parameterMappings;
    private String resultType;
    private String sql;

    private Object parameterObject;
    private MetaObject metaParameters;

    private Map<String, Object> additionalParameters;

    public Object getParameterObject() {
        return parameterObject;
    }

    public BoundSql() {
    }
    public BoundSql(Configuration configuration, String sql, List<ParameterMapping> parameterMappings, Object parameterObject) {
        this.sql = sql;
        this.parameterMappings = parameterMappings;
        this.parameterObject = parameterObject;
        this.additionalParameters = new HashMap<>();
        this.metaParameters = configuration.newMetaObject(additionalParameters);
    }


    public String getParameterType() {
        return parameterType;
    }

    public void setParameterType(String parameterType) {
        this.parameterType = parameterType;
    }

    public List<ParameterMapping> getParameterMappings() {
        return parameterMappings;
    }

    public void setParameterMappings(List<ParameterMapping> parameterMappings) {
        this.parameterMappings = parameterMappings;
    }

    public String getResultType() {
        return resultType;
    }

    public void setResultType(String resultType) {
        this.resultType = resultType;
    }

    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    public void setAdditionalParameter(String key, Object value) {
        metaParameters.setValue(key, value);
    }



}
